package lang;

import java.util.Iterator;

import javax.swing.SpinnerDateModel;

import org.nutz.lang.Strings;

public class StringPractice {

	static void IsEmpty()
	{
		System.out.println(Strings.isEmpty(""));
		System.out.println(Strings.isEmpty(null));
		System.out.println(Strings.isEmpty("\t"));
	}
	
	static void DefaultString()
	{
		System.out.println(Strings.sNull(null, "default null string"));
		System.out.println(Strings.sBlank("\r\n\t", "default blank String"));
	}
	
	static void PadString(){
		System.out.println(Strings.alignLeft("abc", 10, '-'));
		System.out.println(Strings.alignRight("abc", 10, '+'));
		System.out.println(Strings.dup('-', 50));
	}
	
	static void FindGetSet()
	{
		System.out.println(Strings.capitalize("get"+"hello()"));
		System.out.println(Strings.lowerFirst("Field"));
	}
	
	
	static void SplitString()
	{
		String array="a,b,c,,,d,,e,,f,,g".replace(',', ' ');
		String[] ss=Strings.splitIgnoreBlank(array," ");
		System.out.println(array.split(" ").length);
		System.out.println(ss.length);
		for (String string : ss) {
			assert string!=null && ss.length!=0;
		}
	}
	
	
	public static void main(String[] args) {
		IsEmpty();
		DefaultString();
		PadString();
		FindGetSet();
		SplitString();
		final char[] chars=new char[5000];
		for (int i = 0; i < chars.length; i++) {
			chars[i]=(char) i;
		}
		//测试字符转换为字符串哪个快
		new PerformonEfficent(new PerfmonCallback() {
			
			@Override
			public void perfmon() {
				for (char c : chars) {
					String string=c+"";
				}
			}
		},100);
		
		new PerformonEfficent(new PerfmonCallback() {
			
			@Override
			public void perfmon() {
				for (char c : chars) {
					String string=Strings.dup(c, 1);
				}
				
			}
		},100);
	}
}
